package com.Producer;

import com.constant.TopicConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;


@Slf4j
@Component
public class MailMessageProducer {

    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;

    /**
     * 发送消息到kafka用于给用户发邮箱信息
     */
    public void sendMailMsgToKafka(String mail, String msg){

        kafkaTemplate.send(TopicConstant.MAIL_MESSAGE_TOPIC,mail,msg);
        log.info("消息发送到 Kafka:{} -> {}",TopicConstant.MAIN_CACHE_TOPIC,msg);

    }

}
